package com.huike.controller.contract;


import com.huike.dto.ContractDto;
import com.huike.entity.Contract;
import com.huike.result.PageResult;
import com.huike.result.Result;
import com.huike.service.ContractService;
import com.huike.utils.AliOssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.UUID;


@RestController
@RequestMapping("/contract")
public class ContractController {

    @Autowired
    private ContractService contractService;


    @GetMapping("/search")
    public Result<PageResult> queryPage(ContractDto contractDto){

        return contractService.queryPage(contractDto);
    }

    @GetMapping("/find/{id}")
    public Result findById(@PathVariable Integer id){
        return contractService.findById(id);
    }

    @GetMapping("/purchaseCourse/{subject}")
    public Result purchaseCourseList(@PathVariable String subject){
        return contractService.purchaseCourseList(subject);
    }

    @GetMapping("/purchaseCourse")
    public Result purchaseCourseGetList(){
        return contractService.purchaseCourseGetList();
    }

    @GetMapping("/purchaseSubject")
    public Result purchaseSubjectList(){
        return contractService.purchaseSubjectList();
    }
    //渠道列表
    @GetMapping("/channel")
    public Result channelList(){
        return contractService.channelList();
    }
    //活动列表
    @GetMapping("/activity/{id}")
    public Result activityList(@PathVariable String id){
        return contractService.activityList(id);
    }


    /**
     * 文件上传
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public Result<String> upload( MultipartFile file){

       return contractService.uploadPDF(file);
    }
    @PostMapping("/insert")
    public Result insert(@RequestBody Contract contract){
        return contractService.insert(contract);
    }

    @GetMapping
    public Result contractShow(String fileName){
return null;

    }

}
